import { reqIndexData } from '../../api/index'
Page({
  // 初始化数据
  data: {
    bannerList: [], // 轮播图列表
    categoryList: [], // 商品导航数据
    activeList: [], // 活动宣传区域
    hotList: [], // 人气推荐
    guessList: [], // 猜你喜欢
    loading: true,
  },

  // 获取index数据
  async getIndexData () {
    const res = await reqIndexData()
    // const [ bannerList, categoryList, activeList, hotList, guessList ] = res
    // console.log(res)
    this.setData({
      bannerList: res[0].data,
      categoryList: res[1].data,
      activeList: res[2].data,
      hotList: res[3].data,
      guessList: res[4].data,
      loading: false
    })
  },
  onLoad() {
    this.getIndexData()
  },
  // 实现转发, 能够转发给好友 群聊
  onShareAppMessage () {
    return {
      title: '所有的喷然心动,都是你~',
      path: '/pages/index/index',
      imageUrl: '../../assets/images/love.jpg'
    }
  },
  // 能够把小程序分享到朋友圈
  onShareTimeline () {

  }
})
